<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragment::head(~{::title})">
    <meta charset="UTF-8">
    <!--移动端预览-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客新增</title>
    <!--引入sementic-ui模板所需要的js-->
    <link rel="stylesheet" type="text/css" href="../../static/css/semantic.min.css" th:href="@{/css/semantic.min.css}">
    <!--自定义css-->
    <link rel="stylesheet" type="text/css" href="../../static/css/me.css" th:href="@{/css/me.css}">
    <!--引入Markdown插件所需要的CSS-->
    <link rel="stylesheet" type="text/css" href="../../static/lib/editormd/css/editormd.css" th:href="@{/lib/editormd/css/editormd.css"/>
</head>

<body>
    <!--导航-->
    <nav th:replace="admin/_fragment::menu(1)" class="ui inverted attached segment segment m-padded-tb-mini m-shadow-small">
        <div class="ui container">
            <div class="ui inverted secondary stackable menu">
                <h2 class="ui teal header item">后台管理</h2>
                <a href="#" class="m-item active item m-mobile-hide"><i class="small home icon"></i>博客管理</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="small idea icon"></i>分类管理</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="small tags icon"></i>标签管理</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="small idea icon"></i>个人信息</a>
                <div class="right m-item m-mobile-hide menu">
                    <div class="ui dropdown item">
                        <div class="text ">
                            <img class="ui avatar image" th:src="${/images/loginTX.png}">
                            小白
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--menu toggle无任何显示意思-->
        <a href="" class="ui icon menu toggle black button m-right-top m-mobile-show">
            <i class="sidebar icon"></i>
        </a>
    </nav>
    <!--导航 end-->

    <!--二级导航-->
    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a th:href="@{/admin/blogs/input}" href="#" class="active teal item">发布</a>
                <a th:href="@{/admin/blogs}" href="#" class="basic item">列表</a>
            </div>
        </div>
    </div>
    <!--二级导航-->
    <!--中间内容 start-->
    <div class="m-container-small m-padded-tb-big">
        <!--适应移动端手机-->
        <div class="ui container">
    	<form id="blog-form" action="#" th:object="${blog}" th:action="@{/admin/addBlogs}" method="post" class="ui form">
                <input type="hidden" name="id" th:value="*{id}">
                <!--判断是状态-保存、发布....-->
                <input type="hidden" name="publicshed" value="">
                <!--博客来源-->
                <div class="required field">
                    <div class="ui left labeled input">
                        <div class="ui selection compact teal basic dropdown label">
          					<input type="hidden" value="原创" name="flag" th:value="${blog==null}?${blog.flag}:'原创'">
                            <i class="dropdown icon"></i>
                            <div class="text">原创</div>
                            <div class="menu">
                                <div class="item" data-value="原创">原创</div>
                                <div class="item" data-value="转载">转载</div>
                                <div class="item" data-value="翻译">翻译</div>
                            </div>
                        </div>
                        <input type="text" name="title" placeholder="标题" th:value="*{title}">
                    </div>
                </div>
                <!--文章内容-->
                <div class="field">
                    <div id="md-content" style="z-index: 1 !important;">
                                  <textarea style="display:none;" name="content" th:text="*{content}">[TOC]
#### 我是标题
</textarea>
                    </div>
                </div>
                <!--博客分类-->
                <div class="two fields">
                    <div class="field">
                        <div class="ui left labeled action input">
                            <label class="ui compact teal basic label">分类</label>
                            <div class="ui fluid selection dropdown"> 
                                <input type="hidden" name="type.id" th:value="*{type}!=null ? *{type.id}">
                                <i class="dropdown icon"></i>
                                <div class="default text">分类</div>
                                <div class="menu">
                                     <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.name}">分类1</div>
                                    <!--/*-->
                                    <div class="item" data-value="2">分类2</div>
                                    <div class="item" data-value="3">分類3</div>
                                    <!--*/-->
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left labeled action input">
                            <label class="ui compact teal basic label">标签</label>
                            <div class="ui fluid selection multiple search dropdown ">
                                <input type="hidden" name="tagIds" th:value="*{tagIds}"/>
                                <i class="dropdown icon"></i>
                                <div class="default text">标签</div>
                                <div class="menu">
                                   <div th:each="tag : ${tags}" class="item" data-value="1" th:data-value="${tag.id}" th:text="${tag.name}">标签1</div>
                                    <!--/*-->
                                    <div class="item" data-value="2">标签2</div>
                                    <div class="item" data-value="3">标签3</div>
                                    <!--*/-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">首图</label>
                        <input type="text" name="firstPicture" placeholder="首图引用地址" th:value="*{firstPicture}">
                    </div>
                </div>
                <div class="inline fields">
                    <div class="field">
                        <div class="ui checkbox">
                            <!--hidden表示默认未选中-->
                            <input type="checkbox" id="recommend" name="recommend" checked th:checked="*{recommend}" class="hidden">
                            <label for="recommend">推荐</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="shareStatement" name="sharStatement" th:checked="*{sharStatement}" class="hidden">
                            <label for="shareStatement">转载声明</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="appreciation" name="appreciation" th:checked="*{appreciation}" class="hidden">
                            <label for="appreciation">赞赏</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="commentabled" name="commentabled" th:checked="*{commentabled}" class="hidden">
                            <label for="commentabled">评论</label>
                        </div>
                    </div>
                </div>
                <!--表单校验-->
                <!--错误提示-->
                <div class="ui error message">

                </div>

                <!--返回、保存、发布-->
                <div class="ui right aligned container">
                    <!--onclick="window.history.go(-1)返回上一页面-->
                    <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>

                    <button type="button" id="save-btn" class="ui green button">保存</button>

                    <button type="button" id="publish-btn" class="ui teal button">发布</button>
                </div>
            </form>
        </div>
    </div>
    <br>
    <br>
    <!--中间内容 end-->
    <!--底部footer start-->
   <footer th:replace="admin/_fragment::footer" class="ui inverted vertical segment m-padded-tb-massive">
        <div class="ui center aligned container">
            <div class="ui inverted divided stackable grid">
                <div class="three wide column">
                    <div class="ui inverted link list">
                        <h4 class="ui inverted header m-opacity-min">站长微信</h4>
                        <div class="item">
                            <img th:src="${/images/loginTX.png}" CLASS="ui rounded image" alt="" style="width:110px">
                        </div>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header m-opacity-min">最新博客</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item">2019一年收获总结</a>
                        <a href="#" class="item">idea的操作笔记</a>
                        <a href="#" class="item">SpringBoot学习计划</a>
                    </div>
                </div>
                <div class="three wide column">
                    <h4 class="ui inverted header m-opacity-min">联系作者</h4>
                    <div class="ui inverted link list">
                        <a href="#" class="item">b站</a>
                        <a href="#" class="item">QQ:1515177029</a>
                        <a href="#" class="item">邮箱:yerenping@aliyun.com</a>
                    </div>
                </div>
                <div class="seven wide column">
                    <h4 class="ui inverted header m-opacity-min">关于作者</h4>
                    <p class="m-text-thin m-text-spaced m-opacity-min m-text-lined">
                        作者是一名springboot爱好者,是一名正在努力奋斗的学生,主要学习JavaEE开发,Web前端等技术.作者是个喜欢旅行的孩子,目标是游遍全世界！</p>
                </div>
            </div>
            <!--分割线-->
            <div class="ui inverted section divider"></div>
            <p class="m-text-thin m-text-spaced m-opacity-tiny">Copy © 2019 - 2020 作者:小小叶儿 此站仅供个人所有 如有疑问联系作者</p>
        </div>
    </footer>
    <!--底部footer end-->
</body>


 
<!--引入jQuery-->
<script th:src="@{/js/jquery-3.4.1.min.js}"></script>
<!--引入sementic-ui模板所需要的js-->
<script th:src="@{/js/semantic.min.js}"></script>
<!--引入Markdown插件需要引入的js-->
<script th:src="@{/lib/editormd/editormd.min.js}"></script>
<!--声明行内js代码域-->
<script>
var imageUploadURL=location.href.substr(0,location.href.lastIndexOf('/'))+"/uploadImg";
    /*Markdown插件集成*/
    var testEditor;
    $(function () {
        testEditor = editormd("md-content", {
            width: "100%",
            height : 500,
            syncScrolling: true,/*双向滚动*/
            // path    : "../../static/lib/editormd/lib/"
            path: "/lib/editormd/lib/",
            imageUpload : true,
            imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
            imageUploadURL : imageUploadURL
        });
    });
    /*移动端显示导航栏设置*/ 
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });
    /*导航栏用户注销显示*/
    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    $('#save-btn').click(function () {
        $('[name="publicshed"]').val(false);
        $('#blog-form').submit();
    });


    $('#publish-btn').click(function () {
        $('[name="publicshed"]').val(true);
        alert(1);
        $('#blog-form').submit();
    });

    /*表单校验*/
    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'title',
                rules: [{
                    type: 'empty',
                    prompt: '请输入文章标题！'
                }]
            },
            content: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '请输入文章内容！'
                }]
            },
            typeId: {
                identifier: 'type.id',
                rules: [{
                    type: 'empty',
                    prompt: '请选择文章分类！'
                }]
            },
            firstPicture: {
                identifier: 'firstPicture',
                rules: [{
                    type: 'empty',
                    prompt: '请填写首图地址！'
                }]
            },
            description: {
                identifier: 'description ',
                rules: [{
                    type: 'empty',
                    prompt: '请填入博客描述！'
                }]
            }
        }
    });
    $("[name='content']").blur(()=>{
    	console.log(1);
    });  	
</script>

</html>